home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / AppsToGo / DTS.Lib / ViewHierarchy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  27.3 KB  |  1,027 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** Program:     DTS.Lib
  5. ** File:        viewhierarchy.c
  6. ** Written by:  Eric Soldan
  7. **
  8. ** Copyright © 1990-1993 Apple Computer, Inc.
  9. ** All rights reserved.
  10. */
  11.  
  12. /* You may incorporate this sample code into your applications without
  13. ** restriction, though the sample code has been provided "AS IS" and the
  14. ** responsibility for its operation is 100% yours.  However, what you are
  15. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  16. ** after having made changes. If you're going to re-distribute the source,
  17. ** we require that you make it clear in the source that the code was
  18. ** descended from Apple Sample Code, but that you've made changes. */
  19.  
  20.  
  21.  
  22. /*****************************************************************************/
  23.  
  24.  
  25.  
  26. #include "DTS.Lib2.h"
  27. #include "DTS.Lib.protos.h"
  28.  
  29. #ifndef __CTLHANDLER__
  30. #include "CtlHandler.h"
  31. #endif
  32.  
  33. #ifndef __ERRORS__
  34. #include <Errors.h>
  35. #endif
  36.  
  37. #ifndef __FONTS__
  38. #include <Fonts.h>
  39. #endif
  40.  
  41. #ifndef __LISTCONTROL__
  42. #include "ListControl.h"
  43. #endif
  44.  
  45. #ifndef __RESOURCES__
  46. #include <Resources.h>
  47. #endif
  48.  
  49. #ifndef THINK_C
  50. #ifndef __STRINGS__
  51. #include <Strings.h>
  52. #endif
  53. #endif
  54.  
  55. #ifndef __TEXTEDITCONTROL__
  56. #include "TextEditControl.h"
  57. #endif
  58.  
  59.  
  60.  
  61. /*****************************************************************************/
  62.  
  63.  
  64.  
  65. #ifdef powerc
  66. #pragma options align=mac68k
  67. #endif
  68. typedef struct ViewHierFileTypeRec {
  69.     FileStateRec    fileState;
  70.     ConnectRec        connect;
  71.     ViewDoc            vh;
  72. } ViewHierFileTypeRec;
  73. #ifdef powerc
  74. #pragma options align=reset
  75. #endif
  76.  
  77.  
  78. extern short    gTECtl;
  79. extern short    gListCtl;
  80.  
  81. extern short            gPrintPage;            /* Non-zero means we are printing. */
  82. extern TreeObjProcPtr    gTreeObjMethods[];
  83. extern Cursor            *gCursorPtr;
  84. extern TreeObjHndl        gWindowFormats;
  85.  
  86. static void        VHContentClick(WindowPtr window, EventRecord *event, Boolean firstClick);
  87. static Boolean    VHContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough);
  88. static OSErr    VHImageDocument(FileRecHndl frHndl);
  89. static OSErr    VHInitContent(FileRecHndl frHndl, WindowPtr window);
  90. static Boolean    VHDisplayFilter(TEHandle teHndl, EventRecord *event, short *handled);
  91. static void        VHNewView(FileRecHndl frHndl, char *newText, short newTextLen, Boolean updatePList);
  92. static OSErr    VHUpdateInfo(FileRecHndl frHndl, Boolean updatePList);
  93. static Boolean    VHWindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt);
  94.  
  95.  
  96.  
  97. /*****************************************************************************/
  98. /*****************************************************************************/
  99.  
  100. #ifdef applec
  101. #pragma segment ATGViewHier
  102. #endif
  103.  
  104. /*****************************************************************************/
  105. /*****************************************************************************/
  106.  
  107.  
  108.  
  109. /* This is called when a mouse-down event occurs in the content of a window.
  110. ** Other applications might want to call FindControl, TEClick, etc., to
  111. ** further process the click. */
  112.  
  113. void    VHContentClick(WindowPtr window, EventRecord *event, Boolean firstClick)
  114. {
  115. #ifndef __MWERKS__
  116. #pragma unused (firstClick)
  117. #endif
  118.  
  119.     FileRecHndl        frHndl;
  120.     ControlHandle    ctl;
  121.     short            ctlNum, action, len, selStart;
  122.     ListHandle        plist, clist;
  123.     TEHandle        te, display;
  124.     char            newText[33];
  125.     Point            cell;
  126.  
  127.     frHndl = (FileRecHndl)GetWRefCon(window);
  128.  
  129.     ctlNum = IsCtlEvent(window, event, &ctl, &action);
  130.     switch (ctlNum) {
  131.         case 101:
  132.             display = (*frHndl)->d.vh.display;
  133.             te = CTEFindActive(window);
  134.             if (!te)
  135.                 te = display;
  136.             ctl = CTEViewFromTE(te);
  137.             if (te == display) {
  138.                 CTEActivate(true, te);
  139.                 CLActivate(false, CLFindActive(window));
  140.                 CTESetSelect(0, (*te)->teLength, display);
  141.             }
  142.             len = (*te)->selEnd - (selStart = (*te)->selStart);
  143.             if (len > 32)
  144.                 len = 32;
  145.             BlockMove(*((*te)->hText) + selStart, newText, len);
  146.             VHNewView(frHndl, newText, len, true);
  147.             break;
  148.         case 102:
  149.             if (action == 1) {
  150.                 plist = (*frHndl)->d.vh.plist;
  151.                 cell  = LLastClick(plist);
  152.                 len   = 8;
  153.                 LGetCell(newText, &len, cell, plist);
  154.                 VHNewView(frHndl, newText, len, false);
  155.             }
  156.             break;
  157.         case 103:
  158.             if (action == 1) {
  159.                 clist = (*frHndl)->d.vh.clist;
  160.                 cell  = LLastClick(clist);
  161.                 len   = 8;
  162.                 LGetCell(newText, &len, cell, clist);
  163.                 VHNewView(frHndl, newText, len, true);
  164.             }
  165.             break;
  166.     }
  167. }
  168.  
  169.  
  170.  
  171. /*****************************************************************************/
  172.  
  173.  
  174.  
  175. /* This is called when a key event occurs and it is determined that it isn't
  176. ** a menu key. */
  177.  
  178. Boolean    VHContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough)
  179. {
  180. #ifndef __MWERKS__
  181. #pragma unused (passThrough)
  182. #endif
  183.  
  184.     FileRecHndl        frHndl;
  185.     char            key;
  186.     ControlHandle    ctl;
  187.     short            action, selStart, len;
  188.     TEHandle        te, display;
  189.     char            newText[33];
  190.     TreeObjHndl        pobj, cobj;
  191.  
  192.     frHndl = (FileRecHndl)GetWRefCon(window);
  193.     key = event->message & charCodeMask;
  194.  
  195.     if ((key == chEnter) || (key == chReturn)) {
  196.         SelectButton(ctl = (*frHndl)->d.vh.newView);
  197.         display = (*frHndl)->d.vh.display;
  198.         te = CTEFindActive(window);
  199.         if (!te)
  200.             te = display;
  201.         ctl = CTEViewFromTE(te);
  202.         if (te == display) {
  203.             CTEActivate(true, te);
  204.             CLActivate(false, CLFindActive(window));
  205.             CTESetSelect(0, (*te)->teLength, display);
  206.         }
  207.         len = (*te)->selEnd - (selStart = (*te)->selStart);
  208.         if (len > 32)
  209.             len = 32;
  210.         BlockMove(*((*te)->hText) + selStart, newText, len);
  211.         VHNewView(frHndl, newText, len, true);
  212.         return(true);
  213.     }
  214.     if (key == chFwdDelete) {
  215.         if (event->modifiers & optionKey) {
  216.             cobj = (*frHndl)->d.vh.root;
  217.             pobj = (*cobj)->parent;
  218.             if (pobj) {
  219.                 DisposeChild(NO_EDIT, pobj, GetChildNum(cobj));
  220.                 ccpypadhex(newText, 0, 8, 8, (long)pobj);
  221.                 VHNewView(frHndl, newText, 8, true);
  222.             }
  223.         }
  224.     }
  225.  
  226.     return(IsCtlEvent(window, event, &ctl, &action));
  227. }
  228.  
  229.  
  230.  
  231. /*****************************************************************************/
  232.  
  233.  
  234.  
  235. /* Image the document into the current port. */
  236.  
  237. OSErr    VHImageDocument(FileRecHndl frHndl)
  238. {
  239. #ifndef __MWERKS__
  240. #pragma unused (frHndl)
  241. #endif
  242.  
  243.     WindowPtr        curPort;
  244.  
  245.     GetPort(&curPort);
  246.  
  247.     if (!gPrintPage) {                                        /* If not printing... */
  248.         DoDrawControls(curPort, false);                        /* Draw the content controls. */
  249.         OutlineControl((*frHndl)->d.vh.newView);
  250.     }
  251.     else {
  252.         gPrintPage = 0;
  253.     }
  254.  
  255.     return(noErr);
  256. }
  257.  
  258.  
  259.  
  260. /*****************************************************************************/
  261.  
  262.  
  263.  
  264. /* This function does the remaining window initialization. */
  265.  
  266. OSErr    VHInitContent(FileRecHndl frHndl, WindowPtr window)
  267. {
  268.     FileRecPtr        frPtr;
  269.     FileRecHndl        refFrHndl;
  270.     WindowPtr        oldPort;
  271.     ControlHandle    ctl;
  272.     TEHandle        dump, display;
  273.     ListHandle        plist, clist;
  274.     ControlHandle    newView;
  275.     OSErr            err;
  276.  
  277.     GetPort(&oldPort);
  278.     SetPort(window);
  279.  
  280.     err = AddControlSet(window, (*frHndl)->fileState.sfType, kwStandardVis, 0, 0, nil);
  281.     if (err) return(err);
  282.  
  283.     CNum2Ctl(window, 100, &ctl);
  284.     dump = (TEHandle)GetControlReference(ctl);
  285.  
  286.     CNum2Ctl(window, 101, &ctl);
  287.     display = (TEHandle)GetControlReference(ctl);
  288.     CTESetKeyFilter(display, VHDisplayFilter);
  289.  
  290.     CNum2Ctl(window, 102, &ctl);
  291.     plist = (ListHandle)GetControlReference(ctl);
  292.  
  293.     CNum2Ctl(window, 103, &ctl);
  294.     clist = (ListHandle)GetControlReference(ctl);
  295.  
  296.     CNum2Ctl(window, 104, &newView);
  297.  
  298.     frPtr = *frHndl;
  299.     frPtr->d.vh.dump    = dump;
  300.     frPtr->d.vh.display = display;
  301.     frPtr->d.vh.plist   = plist;
  302.     frPtr->d.vh.clist   = clist;
  303.     frPtr->d.vh.newView = newView;
  304.  
  305.     refFrHndl = mDerefRoot(frPtr->d.vh.root)->frHndl;
  306.     NewWindowTitle(window, (*refFrHndl)->fileState.fss.name);
  307.     VHUpdateInfo(frHndl, true);
  308.  
  309.     SetPort(oldPort);
  310.     return(noErr);
  311. }
  312.  
  313.  
  314.  
  315. /*****************************************************************************/
  316.  
  317.  
  318.  
  319. static Boolean    VHWindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt)
  320. {
  321. #ifndef __MWERKS__
  322. #pragma unused (frHndl, window, globalPt)
  323. #endif
  324.  
  325.     SetCursor(gCursorPtr = &qd.arrow);
  326.     return(true);
  327. }
  328.  
  329.  
  330.  
  331. /*****************************************************************************/
  332.  
  333.  
  334.  
  335. Boolean    VHDisplayFilter(TEHandle teHndl, EventRecord *event, short *handled)
  336. {
  337. #ifndef __MWERKS__
  338. #pragma unused (teHndl, handled)
  339. #endif
  340.     char    key;
  341.     short    arrowKey;
  342.  
  343.     key = event->message & charCodeMask;
  344.     arrowKey = ((key >= chLeft) && (key <= chDown));
  345.     if (
  346.         (arrowKey) ||
  347.         (key == chBackspace) ||
  348.         (key == chTab) ||
  349.         ((key >= '0') && (key <= '9')) ||
  350.         ((key >= 'A') && (key <= 'F')) ||
  351.         ((key >= 'a') && (key <= 'f'))
  352.     ) {
  353.         return(false);
  354.     }
  355.  
  356.     return(true);
  357. }
  358.  
  359.  
  360.  
  361. /*****************************************************************************/
  362.  
  363.  
  364.  
  365. /* This function adds the application's controls to a window. */
  366.  
  367. void    VHNewView(FileRecHndl frHndl, char *newText, short newTextLen, Boolean updatePList)
  368. {
  369.     TEHandle    te;
  370.     short        len, i;
  371.     long        newHndl;
  372.     char        workText[33];
  373.  
  374.     if (!newText) {
  375.         newText    = workText;
  376.         newTextLen = 0;
  377.     }
  378.     if (!(len = newTextLen)) {
  379.         te = (*frHndl)->d.vh.display;
  380.         BlockMove(*((*te)->hText), newText, len = (*te)->teLength);
  381.     }
  382.  
  383.     for (newHndl = 0, i = 0; i < len; ++i) {
  384.         if ((newText[i] >= '0') && (newText[i] <= '9')) {
  385.             newHndl *= 16;
  386.             newHndl += (newText[i] - '0');
  387.             continue;
  388.         }
  389.         if ((newText[i] >= 'a') && (newText[i] <= 'f'))
  390.             newText[i] -= 32;
  391.         if ((newText[i] >= 'A') && (newText[i] <= 'F')) {
  392.             newHndl *= 16;
  393.             newHndl += (newText[i] - 'A' + 10);
  394.         }
  395.     }
  396.  
  397.     if (newHndl) {
  398.         GetHandleSize((Handle)newHndl);
  399.         if (!MemError()) {
  400.             (*frHndl)->d.vh.root = (TreeObjHndl)newHndl;
  401.             VHUpdateInfo(frHndl, updatePList);
  402.         }
  403.         else SysBeep(1);
  404.     }
  405. }
  406.  
  407.  
  408.  
  409. /*****************************************************************************/
  410.  
  411.  
  412.  
  413. /* This function adds the application's controls to a window. */
  414.  
  415. OSErr    VHUpdateInfo(FileRecHndl frHndl, Boolean updatePList)
  416. {
  417.     WindowPtr        oldPort;
  418.     TreeObjHndl        root, chndl, phndl;
  419.     TEHandle        dump;
  420.     ListHandle        plist, clist;
  421.     Handle            text;
  422.     char            *cptr, *kcptr;
  423.     long            dataSize, x, v;
  424.     short            *dptr, cnum, depth, ctype;
  425.     Point            cell;
  426.     char            ctext[32], ptext[32];
  427.     RgnHandle        rgn;
  428.     Boolean            customFormat;
  429.     TreeObjProcPtr    proc;
  430.     VHFormatData    cf;
  431.  
  432.     root  = (*frHndl)->d.vh.root;
  433.     dump  = (*frHndl)->d.vh.dump;
  434.     plist = (*frHndl)->d.vh.plist;
  435.     clist = (*frHndl)->d.vh.clist;
  436.  
  437.     DoNumberTree(root);
  438.  
  439.     text = NewHandle(32767);
  440.     if (!text)
  441.         return(MemError());
  442.  
  443.     GetPort(&oldPort);
  444.     SetPort((*frHndl)->fileState.window);
  445.  
  446.     HLock(text);
  447.     cptr = kcptr = StripAddress(*text);
  448.  
  449.     ccpy      (cptr, "$");
  450.     ccatpadhex(cptr, '0', 8, 8, (long)root);
  451.     ccatchr   (cptr, 13, 2);
  452.  
  453.     ccat      (cptr, "$00:        type = $");
  454.     ccatpadhex(cptr, '0', 4, 4, ctype = (*root)->type);
  455.     ccatchr   (cptr, 13, 1);
  456.  
  457.     ccat      (cptr, "$02: numChildren = $");
  458.     ccatpadhex(cptr, '0', 4, 4, (*root)->numChildren);
  459.     ccatchr   (cptr, 13, 1);
  460.  
  461.     ccat      (cptr, "$04:    dataSize = $");
  462.     ccatpadhex(cptr, '0', 8, 8, dataSize = (*root)->dataSize);
  463.     ccatchr   (cptr, 13, 1);
  464.  
  465.     ccat      (cptr, "$08:      treeID = $");
  466.     ccatpadhex(cptr, '0', 8, 8, (*root)->treeID);
  467.     ccatchr   (cptr, 13, 1);
  468.  
  469.     ccat      (cptr, "$0C:      parent = $");
  470.     ccatpadhex(cptr, '0', 8, 8, (long)(*root)->parent);
  471.  
  472.     customFormat = false;
  473.     proc = gTreeObjMethods[ctype];
  474.     if (proc) {                                /* If this object type has a proc...   */
  475.         cptr     += clen(cptr);
  476.         cf.text   = text;
  477.         cf.header = kcptr;
  478.         cf.data   = cptr;
  479.         customFormat = (*proc)(root, VHMESSAGE, (long)&cf);
  480.         HLock(text);
  481.         cptr = kcptr = StripAddress(*text);
  482.         cptr += clen(cptr);
  483.     }
  484.  
  485.     if (!customFormat) {
  486.         dptr = (short *)GetDataPtr(root);
  487.         for (x = 0; (cptr += clen(cptr)), (x < dataSize); x += sizeof(short)) {
  488.             v = *dptr++;
  489.             v &= 0x0000FFFF;
  490.             if ((dataSize - x) == 1) {
  491.                 v >>= 8;
  492.                 v  &= 0x00FF;
  493.             }
  494.             if (!(x & 0x3F)) {
  495.                 ccatchr   (cptr, 13, 2);
  496.                 ccat      (cptr, "$");
  497.                 ccatpadhex(cptr, '0', 8, 8, x + sizeof(TreeObj));
  498.                 ccat      (cptr, ":");
  499.             }
  500.             if (!(x & 0x0F)) {
  501.                 ccatchr(cptr, 13, 1);
  502.                 ccat   (cptr, " ");
  503.             }
  504.             ccat   (cptr, " ");
  505.             if ((dataSize - x) == 1)
  506.                 ccatpadhex(cptr, '0', 2, 2, v);
  507.             else
  508.                 ccatpadhex(cptr, '0', 4, 4, v);
  509.             if ((cptr - kcptr) > 32000) break;
  510.         }
  511.     }
  512.  
  513.     HUnlock(text);
  514.     SetHandleSize(text, cptr - kcptr);
  515.  
  516.     UseControlStyle(CTEViewFromTE(dump));
  517.     DisposeHandle(CTESwapText(dump, text, nil, true));
  518.     UseControlStyle(nil);
  519.  
  520.     UseControlStyle(CLViewFromList(clist));
  521.     LDelRow(0, 0, clist);
  522.     LSetDrawingMode(false, clist);
  523.     cell.h = cell.v = 0;
  524.     for (cnum = (*root)->numChildren; cnum;) {
  525.         chndl = GetChildHndl(root, --cnum);
  526.         ccpypadhex(ctext, '0', 8, 8, (long)chndl);
  527.         LAddRow(1, 0, clist);
  528.         LSetCell(ctext, 8, cell, clist);
  529.     }
  530.     LSetDrawingMode(true, clist);
  531.     rgn = NewRgn();
  532.     GetClip(rgn);
  533.     LUpdate(rgn, clist);
  534.     DisposeRgn(rgn);
  535.     UseControlStyle(nil);
  536.  
  537.     UseControlStyle(CLViewFromList(plist));
  538.     if (updatePList) {
  539.         LDelRow(0, 0, plist);
  540.         LSetDrawingMode(false, plist);
  541.         cell.h = cell.v = 0;
  542.         for (depth = 0, phndl = root; phndl; phndl = (*phndl)->parent, ++depth) {
  543.             ccpypadhex(ptext, '0', 8, 8, (long)phndl);
  544.             LAddRow(1, 0, plist);
  545.             LSetCell(ptext, 8, cell, plist);
  546.         }
  547.         cell.v = depth - 1;
  548.         LSetSelect(true, cell, plist);
  549.         LAutoScroll(plist);
  550.         LSetDrawingMode(true, plist);
  551.         rgn = NewRgn();
  552.         GetClip(rgn);
  553.         LUpdate(rgn, plist);
  554.         DisposeRgn(rgn);
  555.     }
  556.     else LAutoScroll(plist);
  557.     UseControlStyle(nil);
  558.  
  559.     SetPort(oldPort);
  560.     return(noErr);
  561. }
  562.  
  563.  
  564.  
  565. /*****************************************************************************/
  566. /*****************************************************************************/
  567.  
  568.  
  569.  
  570. OSErr    VHInitDocument(FileRecHndl frHndl)
  571. {
  572.     FileRecPtr    frPtr;
  573.     FileRecHndl    refFrHndl;
  574.     WindowPtr    window;
  575.  
  576.     frPtr = *frHndl;
  577.     if (!gWindowFormats) {
  578.         frPtr->fileState.windowID   = rVHWindow;
  579.         frPtr->fileState.attributes = kwVHAppWindow;
  580.     }
  581.     frPtr->fileState.calcFrameRgnProc        = nil;
  582.     frPtr->fileState.contentClickProc        = VHContentClick;
  583.     frPtr->fileState.contentKeyProc          = VHContentKey;
  584.     frPtr->fileState.drawFrameProc           = nil;
  585.     frPtr->fileState.freeDocumentProc        = nil;
  586.     frPtr->fileState.freeWindowProc          = nil;
  587.     frPtr->fileState.imageProc               = VHImageDocument;
  588.     frPtr->fileState.initContentProc         = VHInitContent;
  589.     frPtr->fileState.readDocumentProc        = nil;
  590.     frPtr->fileState.readDocumentHeaderProc  = nil;
  591.     frPtr->fileState.resizeContentProc       = nil;
  592.     frPtr->fileState.scrollFrameProc         = nil;
  593.     frPtr->fileState.undoFixupProc           = nil;
  594.     frPtr->fileState.windowCursorProc        = VHWindowCursor;
  595.     frPtr->fileState.writeDocumentProc       = nil;
  596.     frPtr->fileState.writeDocumentHeaderProc = nil;
  597.         /* View Hierarchy method declarations. */
  598.  
  599.     /* Document-specific fields are already initialized to 0, so we do nothing. */
  600.  
  601.     for (window = nil; (window = GetNextWindow(window, 0)) != nil;) {
  602.         if (!((WindowPeek)window)->visible) continue;
  603.         refFrHndl = (FileRecHndl)GetWRefCon(window);
  604.         if (refFrHndl) {
  605.             if ((*refFrHndl)->fileState.defaultDoc) {
  606.                 (*frHndl)->d.vh.root = (*refFrHndl)->d.vh.root;
  607.                     /* This view hierarchy window, which isn't created yet, will reference
  608.                     ** the data in the topmost window that uses the default document
  609.                     ** architecture.  As the view hierarchy window is only for debugging
  610.                     ** purposes, there is no prevision to guarantee that the data being
  611.                     ** pointed to will continue to exist or continue to be valid.
  612.                     ** The document that this references could be closed, and therefore
  613.                     ** the reference would point to non-existent data.  (You are warned.) */
  614.                 return(noErr);
  615.             }
  616.         }
  617.     } 
  618.  
  619.     return(memFullErr);
  620.         /* Memory really isn't full.  We just need to pass back an error so that
  621.         ** the application knows that the view hierarchy document wasn't successfully
  622.         ** created.  It wasn't successfull created because it couldn't find any documents
  623.         ** that use the document hierarchy.  This really shouldn't occur, as the application
  624.         ** shouldn't have the menu option available for the view hierarchy window if there
  625.         ** is nothing to view.  However, since the view hierarchy window is just for
  626.         ** debugging, it seems annoying to demand that the application set the state of
  627.         ** the menu item correctly.  Returning any error here should be enough for the
  628.         ** application to be graceful. */
  629. }
  630.  
  631.  
  632.  
  633. /*****************************************************************************/
  634.  
  635.  
  636.  
  637. long    VHFileTypeSize(void)
  638. {
  639.     return(sizeof(ViewHierFileTypeRec));
  640. }
  641.  
  642.  
  643.  
  644. /*****************************************************************************/
  645.  
  646.  
  647.  
  648. void    VHRootInfo(TreeObjHndl root, char *cptr)
  649. {
  650.     ccat      (cptr, "$10: TRootObj:");
  651.     ccatchr   (cptr, 13, 1);
  652.     ccat      (cptr, "  $00: undo        = $");
  653.     ccatpadhex(cptr, '0', 8, 8, (long)mDerefUndo(root)->root);
  654.     ccatchr   (cptr, 13, 1);
  655.     ccat      (cptr, "  $04: frHndl      = $");
  656.     ccatpadhex(cptr, '0', 8, 8, (long)mDerefUndo(root)->frHndl);
  657.     ccatchr   (cptr, 13, 1);
  658. }
  659.  
  660.  
  661.  
  662. /*****************************************************************************/
  663.  
  664.  
  665.  
  666. void    VHFileRecInfo(TreeObjHndl root, char *cptr)
  667. {
  668.     FileRecHndl    frHndl;
  669.     Str255        str;
  670.     char        hstate;
  671.     Rect        rct;
  672.     long        offset;
  673.  
  674.     frHndl = mDerefRoot(root)->frHndl;
  675.     hstate = LockHandleHigh((Handle)frHndl);
  676.  
  677.     ccat   (cptr, "(*frHndl)->fileState:");
  678.     ccatchr(cptr, 13, 1);
  679.     ccat   (cptr, "  sfType                  = '");
  680.     BlockMove(&(*frHndl)->fileState.sfType, str, sizeof(long));
  681.     str[sizeof(long)] = 0;
  682.     ccat   (cptr, (char *)str);
  683.     ccat   (cptr, "'");
  684.     ccatchr(cptr, 13, 1);
  685.  
  686.     ccat   (cptr, "  defaultDoc              = ");
  687.     ccatdec(cptr, (*frHndl)->fileState.defaultDoc);
  688.     ccatchr(cptr, 13, 1);
  689.  
  690.     ccat      (cptr, "  movie                   = $");
  691.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.movie);
  692.     ccatchr   (cptr, 13, 1);
  693.  
  694.     ccat   (cptr, "  movieResID              = ");
  695.     ccatdec(cptr, (*frHndl)->fileState.movieResID);
  696.     ccatchr(cptr, 13, 1);
  697.  
  698.     ccat      (cptr, "  movieFlags              = $");
  699.     ccatpadhex(cptr, '0', 4, 4, (*frHndl)->fileState.movieFlags);
  700.     ccatchr   (cptr, 13, 1);
  701.  
  702.     ccat   (cptr, "  movieDataRefWasChanged  = ");
  703.     ccatdec(cptr, (*frHndl)->fileState.movieDataRefWasChanged);
  704.     ccatchr(cptr, 13, 1);
  705.  
  706.     ccat   (cptr, "  docDirty                = ");
  707.     ccatdec(cptr, (*frHndl)->fileState.docDirty);
  708.     ccatchr(cptr, 13, 1);
  709.  
  710.     ccat   (cptr, "  modNum                  = ");
  711.     ccatdec(cptr, (*frHndl)->fileState.modNum);
  712.     ccatchr(cptr, 13, 1);
  713.  
  714.     ccat   (cptr, "  modTick                 = ");
  715.     ccatdec(cptr, (*frHndl)->fileState.modTick);
  716.     ccatchr(cptr, 13, 1);
  717.  
  718.     ccat   (cptr, "  readOnly                = ");
  719.     ccatdec(cptr, (*frHndl)->fileState.readOnly);
  720.     ccatchr(cptr, 13, 1);
  721.  
  722.     ccat   (cptr, "  refNum                  = ");
  723.     ccatdec(cptr, (*frHndl)->fileState.refNum);
  724.     ccatchr(cptr, 13, 1);
  725.  
  726.     ccat   (cptr, "  resRefNum               = ");
  727.     ccatdec(cptr, (*frHndl)->fileState.resRefNum);
  728.     ccatchr(cptr, 13, 1);
  729.  
  730.     ccat   (cptr, "  fss.vRefNum             = ");
  731.     ccatdec(cptr, (*frHndl)->fileState.fss.vRefNum);
  732.     ccatchr(cptr, 13, 1);
  733.  
  734.     ccat      (cptr, "  fss.parID               = $");
  735.     ccatpadhex(cptr, '0', 8, 8, (*frHndl)->fileState.fss.parID);
  736.     ccatchr   (cptr, 13, 1);
  737.  
  738.     ccat   (cptr, "  fss.name                = ");
  739.     pcpy   (str, (*frHndl)->fileState.fss.name);
  740.     p2c    (str);
  741.     ccat   (cptr, (char *)str);
  742.     ccatchr(cptr, 13, 1);
  743.  
  744.     ccat   (cptr, "  windowID                = ");
  745.     ccatnum(cptr, (*frHndl)->fileState.windowID, 10);
  746.     ccatchr(cptr, 13, 1);
  747.  
  748.     ccat      (cptr, "  window                  = $");
  749.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.window);
  750.     ccatchr   (cptr, 13, 1);
  751.  
  752.     cptr += clen(cptr);
  753.  
  754.     ccat      (cptr, "  getDocWindow            = $");
  755.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.getDocWindow);
  756.     ccatchr   (cptr, 13, 1);
  757.  
  758.     ccat      (cptr, "  calcFrameRgnProc        = $");
  759.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.calcFrameRgnProc);
  760.     ccatchr   (cptr, 13, 1);
  761.  
  762.     ccat      (cptr, "  contentClickProc        = $");
  763.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.contentClickProc);
  764.     ccatchr   (cptr, 13, 1);
  765.  
  766.     ccat      (cptr, "  contentKeyProc          = $");
  767.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.contentKeyProc);
  768.     ccatchr   (cptr, 13, 1);
  769.  
  770.     ccat      (cptr, "  drawFrameProc           = $");
  771.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.drawFrameProc);
  772.     ccatchr   (cptr, 13, 1);
  773.  
  774.     ccat      (cptr, "  freeDocumentProc        = $");
  775.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.freeDocumentProc);
  776.     ccatchr   (cptr, 13, 1);
  777.  
  778.     ccat      (cptr, "  freeWindowProc          = $");
  779.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.freeWindowProc);
  780.     ccatchr   (cptr, 13, 1);
  781.  
  782.     ccat      (cptr, "  imageProc               = $");
  783.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.imageProc);
  784.     ccatchr   (cptr, 13, 1);
  785.  
  786.     ccat      (cptr, "  initContentProc         = $");
  787.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.initContentProc);
  788.     ccatchr   (cptr, 13, 1);
  789.  
  790.     ccat      (cptr, "  readDocumentProc        = $");
  791.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.readDocumentProc);
  792.     ccatchr   (cptr, 13, 1);
  793.  
  794.     ccat      (cptr, "  readDocumentHeaderProc  = $");
  795.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.readDocumentHeaderProc);
  796.     ccatchr   (cptr, 13, 1);
  797.  
  798.     ccat      (cptr, "  resizeContentProc       = $");
  799.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.resizeContentProc);
  800.     ccatchr   (cptr, 13, 1);
  801.  
  802.     ccat      (cptr, "  scrollFrameProc         = $");
  803.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.scrollFrameProc);
  804.     ccatchr   (cptr, 13, 1);
  805.  
  806.     ccat      (cptr, "  undoFixupProc           = $");
  807.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.undoFixupProc);
  808.     ccatchr   (cptr, 13, 1);
  809.  
  810.     ccat      (cptr, "  windowCursorProc        = $");
  811.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.windowCursorProc);
  812.     ccatchr   (cptr, 13, 1);
  813.  
  814.     ccat      (cptr, "  writeDocumentProc       = $");
  815.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.writeDocumentProc);
  816.     ccatchr   (cptr, 13, 1);
  817.  
  818.     ccat      (cptr, "  writeDocumentHeaderProc = $");
  819.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.writeDocumentHeaderProc);
  820.     ccatchr   (cptr, 13, 1);
  821.  
  822.     ccat      (cptr, "  adjustMenuItemsProc     = $");
  823.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.adjustMenuItemsProc);
  824.     ccatchr   (cptr, 13, 1);
  825.  
  826.     ccat      (cptr, "  doMenuItemProc          = $");
  827.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.doMenuItemProc);
  828.     ccatchr   (cptr, 13, 1);
  829.  
  830.     cptr += clen(cptr);
  831.  
  832.     ccat      (cptr, "  attributes              = $");
  833.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.attributes);
  834.     ccatchr   (cptr, 13, 1);
  835.  
  836.     ccat   (cptr, "  windowSizeBounds        = ($");
  837.     rct = (*frHndl)->fileState.windowSizeBounds;
  838.     ccatpadhex(cptr, 0, 4, 4, rct.top);
  839.     ccat      (cptr, ",$");
  840.     ccatpadhex(cptr, 0, 4, 4, rct.left);
  841.     ccat      (cptr, ",");
  842.     ccatchr   (cptr, 13, 1);
  843.     ccatchr   (cptr, ' ', 29);
  844.     ccat      (cptr, "$");
  845.     ccatpadhex(cptr, 0, 4, 4, rct.bottom);
  846.     ccat      (cptr, ",$");
  847.     ccatpadhex(cptr, 0, 4, 4, rct.right);
  848.     ccat      (cptr, ")");
  849.     ccatchr   (cptr, 13, 1);
  850.  
  851.     ccat      (cptr, "  hScroll                 = $");
  852.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.hScroll);
  853.     ccatchr   (cptr, 13, 1);
  854.  
  855.     ccat      (cptr, "  vScroll                 = $");
  856.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.vScroll);
  857.     ccatchr   (cptr, 13, 1);
  858.  
  859.     ccat   (cptr, "  hScrollIndent           = ");
  860.     ccatdec(cptr, (*frHndl)->fileState.hScrollIndent);
  861.     ccatchr(cptr, 13, 1);
  862.  
  863.     ccat   (cptr, "  vScrollIndent           = ");
  864.     ccatdec(cptr, (*frHndl)->fileState.vScrollIndent);
  865.     ccatchr(cptr, 13, 1);
  866.  
  867.     ccat   (cptr, "  leftSidebar             = ");
  868.     ccatdec(cptr, (*frHndl)->fileState.leftSidebar);
  869.     ccatchr(cptr, 13, 1);
  870.  
  871.     ccat   (cptr, "  topSidebar              = ");
  872.     ccatdec(cptr, (*frHndl)->fileState.topSidebar);
  873.     ccatchr(cptr, 13, 1);
  874.  
  875.     ccat   (cptr, "  hArrowVal               = ");
  876.     ccatdec(cptr, (*frHndl)->fileState.hArrowVal);
  877.     ccatchr(cptr, 13, 1);
  878.  
  879.     ccat   (cptr, "  vArrowVal               = ");
  880.     ccatdec(cptr, (*frHndl)->fileState.vArrowVal);
  881.     ccatchr(cptr, 13, 1);
  882.  
  883.     ccat   (cptr, "  hPageVal                = ");
  884.     ccatdec(cptr, (*frHndl)->fileState.hPageVal);
  885.     ccatchr(cptr, 13, 1);
  886.  
  887.     ccat   (cptr, "  vPageVal                = ");
  888.     ccatdec(cptr, (*frHndl)->fileState.vPageVal);
  889.     ccatchr(cptr, 13, 2);
  890.  
  891.     cptr += clen(cptr);
  892.  
  893.     ccat   (cptr, "(*frHndl)->connect:");
  894.     ccatchr(cptr, 13, 1);
  895.     ccat   (cptr, "  windowTag[0]             = ");
  896.     ccatdec(cptr, (*frHndl)->connect.windowTag[0]);
  897.     ccatchr(cptr, 13, 1);
  898.  
  899.     ccat   (cptr, "  windowTag[1]             = ");
  900.     ccatdec(cptr, (*frHndl)->connect.windowTag[1]);
  901.     ccatchr(cptr, 13, 1);
  902.  
  903.     ccat   (cptr, "  connected                = ");
  904.     ccatdec(cptr, (*frHndl)->connect.connected);
  905.     ccatchr(cptr, 13, 1);
  906.  
  907.     ccat   (cptr, "  remoteLoc.descriptorType = '");
  908.     BlockMove(&(*frHndl)->connect.remoteLoc.descriptorType, str, sizeof(long));
  909.     str[sizeof(long)] = 0;
  910.     ccat   (cptr, (char *)str);
  911.     ccat   (cptr, "'");
  912.     ccatchr(cptr, 13, 1);
  913.  
  914.     ccat      (cptr, "  remoteLoc.dataHandle     = $");
  915.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->connect.remoteLoc.dataHandle);
  916.     ccatchr   (cptr, 13, 1);
  917.  
  918.     ccat   (cptr, "  remoteName    = ");
  919.     pcpy   (str, (*frHndl)->connect.remoteName);
  920.     p2c    (str);
  921.     ccat   (cptr, (char *)str);
  922.     ccatchr(cptr, 13, 1);
  923.  
  924.     ccat   (cptr, "  remoteZone    = ");
  925.     pcpy   (str, (*frHndl)->connect.remoteZone);
  926.     p2c    (str);
  927.     ccat   (cptr, (char *)str);
  928.     ccatchr(cptr, 13, 1);
  929.  
  930.     ccat   (cptr, "  remoteMachine = ");
  931.     pcpy   (str, (*frHndl)->connect.remoteMachine);
  932.     p2c    (str);
  933.     ccat   (cptr, (char *)str);
  934.     ccatchr(cptr, 13, 2);
  935.  
  936.     ccat   (cptr, "  remotePath    = ");
  937.     pcpy   (str, (*frHndl)->connect.remotePath);
  938.     p2c    (str);
  939.     ccat   (cptr, (char *)str);
  940.     ccatchr(cptr, 13, 2);
  941.  
  942.     ccat   (cptr, "  remoteApp     = ");
  943.     pcpy   (str, (*frHndl)->connect.remoteApp);
  944.     p2c    (str);
  945.     ccat   (cptr, (char *)str);
  946.     ccatchr(cptr, 13, 2);
  947.  
  948.     cptr += clen(cptr);
  949.  
  950.     ccat   (cptr, "(*frHndl)->d.doc.fhInfo:");
  951.     ccatchr(cptr, 13, 1);
  952.     ccat   (cptr, "  version       = ");
  953.     ccatdec(cptr, (*frHndl)->d.doc.fhInfo.version);
  954.     ccatchr(cptr, 13, 1);
  955.  
  956.     ccat   (cptr, "  printRecValid = ");
  957.     ccatdec(cptr, (*frHndl)->d.doc.fhInfo.printRecValid);
  958.     ccatchr(cptr, 13, 1);
  959.  
  960.     ccat   (cptr, "  print         = (char *)(*frHndl) + $");
  961.     offset  = (long)StripAddress(&(*frHndl)->d.doc.fhInfo.print);
  962.     offset -= (long)StripAddress(*frHndl);
  963.     ccatpadhex(cptr, '0', 4, 4, (long)offset);
  964.     ccatchr   (cptr, 13, 1);
  965.  
  966.     ccat   (cptr, "  structureRect = ($");
  967.     rct = (*frHndl)->d.doc.fhInfo.structureRect;
  968.     ccatpadhex(cptr, 0, 4, 4, rct.top);
  969.     ccat      (cptr, ",$");
  970.     ccatpadhex(cptr, 0, 4, 4, rct.left);
  971.     ccat      (cptr, ",$");
  972.     ccatpadhex(cptr, 0, 4, 4, rct.bottom);
  973.     ccat      (cptr, ",$");
  974.     ccatpadhex(cptr, 0, 4, 4, rct.right);
  975.     ccat      (cptr, ")");
  976.     ccatchr   (cptr, 13, 1);
  977.  
  978.     ccat   (cptr, "  contentRect   = ($");
  979.     rct = (*frHndl)->d.doc.fhInfo.contentRect;
  980.     ccatpadhex(cptr, 0, 4, 4, rct.top);
  981.     ccat      (cptr, ",$");
  982.     ccatpadhex(cptr, 0, 4, 4, rct.left);
  983.     ccat      (cptr, ",$");
  984.     ccatpadhex(cptr, 0, 4, 4, rct.bottom);
  985.     ccat      (cptr, ",$");
  986.     ccatpadhex(cptr, 0, 4, 4, rct.right);
  987.     ccat      (cptr, ")");
  988.     ccatchr   (cptr, 13, 1);
  989.  
  990.     ccat   (cptr, "  stdState      = ($");
  991.     rct = (*frHndl)->d.doc.fhInfo.stdState;
  992.     ccatpadhex(cptr, 0, 4, 4, rct.top);
  993.     ccat      (cptr, ",$");
  994.     ccatpadhex(cptr, 0, 4, 4, rct.left);
  995.     ccat      (cptr, ",$");
  996.     ccatpadhex(cptr, 0, 4, 4, rct.bottom);
  997.     ccat      (cptr, ",$");
  998.     ccatpadhex(cptr, 0, 4, 4, rct.right);
  999.     ccat      (cptr, ")");
  1000.     ccatchr   (cptr, 13, 1);
  1001.  
  1002.     ccat   (cptr, "  userState     = ($");
  1003.     rct = (*frHndl)->d.doc.fhInfo.userState;
  1004.     ccatpadhex(cptr, 0, 4, 4, rct.top);
  1005.     ccat      (cptr, ",$");
  1006.     ccatpadhex(cptr, 0, 4, 4, rct.left);
  1007.     ccat      (cptr, ",$");
  1008.     ccatpadhex(cptr, 0, 4, 4, rct.bottom);
  1009.     ccat      (cptr, ",$");
  1010.     ccatpadhex(cptr, 0, 4, 4, rct.right);
  1011.     ccat      (cptr, ")");
  1012.     ccatchr   (cptr, 13, 1);
  1013.  
  1014.     ccat   (cptr, "  hDocSize      = ");
  1015.     ccatdec(cptr, (*frHndl)->d.doc.fhInfo.hDocSize);
  1016.     ccatchr(cptr, 13, 1);
  1017.  
  1018.     ccat   (cptr, "  vDocSize      = ");
  1019.     ccatdec(cptr, (*frHndl)->d.doc.fhInfo.vDocSize);
  1020.     ccatchr(cptr, 13, 1);
  1021.  
  1022.     HSetState((Handle)frHndl, hstate);
  1023. }
  1024.  
  1025.  
  1026.  
  1027.